/**
 * Created by Lannis on 2017/4/26.
 */
var Lighting;
(function (Lighting) {
    var Scene = (function () {
        function Scene() {
        }
        Scene.prototype.createScene = function (id, width, height) {
            var canvasElement = document.createElement('canvas');
            canvasElement.id = id;
            canvasElement.width = width;
            canvasElement.height = height;
            canvasElement.style.backgroundColor = "black";
            document.body.appendChild(canvasElement);
            window["renderScene"] = canvasElement;
            console.log("%cSUCCESS:Create Scene!SceneId:" + id, "color:green");
            return this;
        };
        ;
        Scene.prototype.resizeSizeTo = function (renderSceneId, newWidth, newHeight) {
            if (this.getScene(renderSceneId)) {
                window[renderSceneId].width = newWidth;
                window[renderSceneId].height = newHeight;
                console.log("%cSUCCESS:Resize Scene Size!SceneId:" + renderSceneId, "color:green");
            }
        };
        Scene.prototype.getScene = function (renderSceneId) {
            if (window[renderSceneId]) {
                return window[renderSceneId];
            }
            else {
                console.log("%cFailed:Get Scene,SceneId:" + renderSceneId, "color:red");
                return false;
            }
        };
        Scene.prototype.addClickListener = function (canvasElement) {
            var that = new Lighting.Firework(canvasElement);
            canvasElement.onclick = function (e) {
                var clickPosition = {
                    x: e.clientX,
                    y: e.clientY
                };
                var theta2;
                if (clickPosition.x != that.startPosition.x) {
                    theta2 = Tools.getAngle2(clickPosition, that.startPosition);
                    if (clickPosition.x < that.startPosition.x) {
                        theta2 = (Math.PI - theta2);
                    }
                }
                else {
                    theta2 = Math.PI / 2;
                }
                that.start(theta2);
            };
            console.log(canvasElement);
        };
        return Scene;
    }());
    Lighting.Scene = Scene;
})(Lighting || (Lighting = {}));
